-- Smoke tests for syslogger (since GP syslogger code is divergent from upstream)

create or replace function log_and_retrieve_master(log_message text)
returns table (log_msg text) as
$$
declare
  session_id text;
begin
  raise log '%', log_message;

  -- We need to check only latest logs (otherwise we will get all the logs
  -- including logs generated by previous callings since we cannot delete
  -- previous logs)
  return query select logmessage from gp_toolkit.gp_log_master_concise where logmessage = log_message order by logtime desc limit 1;
end;
$$ language plpgsql;

select log_and_retrieve_master('message with a " mark');
select log_and_retrieve_master('message with two "" mark');
select log_and_retrieve_master('message with three """ mark');
select log_and_retrieve_master('message with foo"');
select log_and_retrieve_master('message with ""foo""bar"');
select log_and_retrieve_master('message with no quotes');
